package com.liuyanban.interceptor;

import com.liuyanban.domain.user.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

public class LoginInterceptor extends MethodFilterInterceptor {

	@Override
	protected String doIntercept(ActionInvocation invoker) throws Exception {
		/**
		 * 判断session中的user是否为空
		 */
		User user = (User) ActionContext.getContext().getSession().get("user");
		if (null == user) {
			return "login";
		}
		return invoker.invoke();
	}

}
